package com.hbnu.mapper;

import com.hbnu.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Select("select * from user where uid=#{uid} and password=#{password}")
    User getUserByUidAndPassword(String uid,String password);

    @Update("update user set address=#{address} where uid=#{uid}")
    void updateUserAddressByUid(String uid,String address);

    @Update("update user set uname=#{uname} where uid=#{uid}")
    void updateUserUnameByUid(String uid,String uname);

    @Update("update user set telephone=#{telephone} where uid=#{uid}")
    void updateUserTelephoneByUid(String uid,String telephone);

    @Update("update user set password=#{newpwd} where uid=#{uid} and password=#{oldpwd}")
    int updateUserPassword(String uid,String oldpwd,String newpwd);

    @Insert("insert into user (uid,password,uname) value (#{uid},#{password},#{uname})")
    void insertUser(String uid,String password,String uname);
}
